package com.aliyun.gts;

import com.aliyun.gts.sso.context.SFLoginAccountContext;
import com.aliyun.gts.sso.domain.LoginAccount;
import com.aliyun.gts.sso.domain.LoginInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * Created by 鸿度 on 2024-06-18 15:52.
 */
@Slf4j
@Controller
public class IndexController {

    @RequestMapping(value = {"/home", "/", ""})
    public String index(Model model) {
        LoginInfo loginInfo = SFLoginAccountContext.getLoginInfo();
        assert loginInfo != null;
        if (loginInfo.getLoginStatus().getLoginStatus() == 200) {
            model.addAttribute("accountId", loginInfo.getLoginAccount().getGuid());
            model.addAttribute("accountName", loginInfo.getLoginAccount().getUserName());
            model.addAttribute("accountPhone", loginInfo.getLoginAccount().getPhone());
            model.addAttribute("accountCode", loginInfo.getLoginAccount().getUserCode());
            model.addAttribute("accountCookie", loginInfo.getLoginAccount().getCookie());
            model.addAttribute("accountLoginStatus", loginInfo.getLoginStatus().getLoginStatus());
        } else {
            model.addAttribute("accountLoginStatus", loginInfo.getLoginStatus().getLoginStatus());
        }
        return "index";
    }

}
